package com.xiyu.service.repository.fee.recharge;

import com.xiyu.service.model.elder.info.ElderInfoFetcher;
import com.xiyu.service.model.fee.recharge.FeeRechargeFetcher;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryInput;
import com.xiyu.service.model.fee.recharge.FeeRecharge;
import com.xiyu.service.model.fee.recharge.FeeRechargeTable;
import org.babyfish.jimmer.spring.repository.JRepository;
import org.babyfish.jimmer.Page;

import java.util.Optional;

public interface FeeRechargeRepository extends JRepository<FeeRecharge, Long> {
    FeeRechargeTable feeRechargeTable = FeeRechargeTable.$;

    default Page<FeeRecharge> pageQuery(FeeRechargePageQueryInput inputVO){
        return sql().createQuery(feeRechargeTable)
                .orderBy(feeRechargeTable.id().desc())
                .select(feeRechargeTable.fetch(FeeRechargeFetcher.$.allTableFields()
                        .elder(ElderInfoFetcher.$.allTableFields())))
                .fetchPage(inputVO.getPageNo() - 1, inputVO.getPageSize());
    }

    Optional<FeeRecharge> findByElderId(Long elderId);

}